﻿/*
    Zeus GoogleMap Helper
*/

var markOption = {
    position: null,
    map: null,
    title: null,
    icon: null
};

ZEUS.GMAP = {
    validateMarkOption: function () {
        if (markOption.position == null) {
            ZEUS.DEBUG.log("Mark Option: position not specified!");
            return false;
        }
        if (markOption.map == null) {
            ZEUS.DEBUG.log("Mark Option: map not specified!");
            return false;
        }
        if (markOption.title == null) {
            ZEUS.DEBUG.log("Mark Option: title not specified!");
            return false;
        }
        if (markOption.icon == null) {
            ZEUS.DEBUG.log("Mark Option: icon not specified!");
            return false;
        }

        return true;
    },

    // setup marker on map
    markOnMap: function () {
        var marker;

        if (this.validateMarkOption()) {
            marker = new google.maps.Marker({
                position: markOption.position,
                map: markOption.map,
                title: markOption.title,
                icon: markOption.icon
            });
        }

        return marker;
    },

    // popup info window
    msgBox: function (map, marker, info) {
        // Creating the event listener. It now has access to the values of
        // i and marker as they were during its creation
        google.maps.event.addListener(marker, 'click', function () {

            // Check to see if we already have an InfoWindow  
            var infowindow = new google.maps.InfoWindow();
            
            // Setting the content of the InfoWindow
            infowindow.setContent(info);

            // Tying the InfoWindow to the marker 
            infowindow.open(map, marker);
        });
    }
};
